//
//  CYDataSourceDelegate.h
//  CaiYun
//
//  Created by 今日信息科技 on 2017/6/9.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

/**
 * @pragma 填充自定义cell的数据
 */
typedef void(^cellback)(id cell, id data);

/**
 * @pragma 返回选中的cell
 */
typedef void(^selectedCell)(NSIndexPath * index);


/**
 *@监听tableview/collectionview的滚动事件
 */
@protocol CYScrollDelegate <NSObject>
- (void)scrollDelegate:(UIScrollView *)scrollView;
@end





@interface CYDataSource : NSObject <UITableViewDataSource>
/**
 *@pragma  datasource的cell的资源
 */
@property (nonatomic, copy) NSMutableArray <id>*dataArr;
///**
// *@pragma  datasource的cell的资源
// */
//@property (nonatomic, copy) NSMutableDictionary *dataDic;
/**
 *@pragma cell的标识符,可以通过改变identifier来随意更换cell布局
 */
@property (nonatomic, copy) NSString *identifier;
/**
 *@pragma 是否复用
 */
@property (nonatomic, assign) BOOL isMulti;
- (instancetype)initWithData:(NSArray *)data identifier:(NSString *)identifier block:(cellback)block;
//- (instancetype)initWithDict:(NSDictionary *)dict identifier:(NSString *)identifier block:(cellback)block;
@end




@interface CYDelegate : NSObject <UITableViewDelegate>
/**
 *@pragma cell的高度
 */
@property (nonatomic, assign) CGFloat height;
/**
 *@pragma delegate的footer&header视图数组
 */
@property (nonatomic, strong) NSArray *views;
/**
 *@pragma 返回的数组内容是高度，
 */
@property (nonatomic, strong) NSArray *cellHeights;
/**
 *@pragma 选中cell是否恢复
 */
@property (nonatomic, assign) BOOL deselect;
@property (nonatomic, weak) id<CYScrollDelegate>delegate;
/**
 *@pragma height:cell的行高 views:section的footerview和headerview的数组
 *views = @[@{@"headerView":headerview,@"headerHeight":headerHeight},{@"footerView":footerView,@"footerHeight":footerHeight},
 *          @{@"headerView":headerview,@"headerHeight":headerHeight},{@"footerView":footerView,@"footerHeight":footerHeight}];
 */
- (instancetype)initWithCellHeight:(CGFloat )height views:(NSArray *)views  block:(selectedCell)block;
/**
 *@pragma 根据内容自适应cell的高度
 * size 字体的大小
 * array 数据
 * views tableview的headerview和footderview
 */
- (instancetype)initWithAutoHeight:(NSArray *)array views:(NSArray *)views  block:(selectedCell)block;
@end






/**
 * @pragma 返回cell，单个cell的数据，cell的index
 */
typedef void(^collectionCellBack) (id cell , id data, id index);

/**
 *@pragma 返回选中的cell,监听的collection滚动的scrollview.contentoffset.y
 */

@interface CYCollectionDataSource : NSObject <UICollectionViewDataSource>
/**
 *@pragma collection的数据源
 */
@property (nonatomic, copy) NSMutableArray *dataArr;
- (instancetype)initWithData:(NSMutableArray *)data identifier:(NSString *)identifier views:(NSArray *)views block:(collectionCellBack)block;

@end







@interface CYCollectionDelegate : NSObject  <UICollectionViewDelegate>
@property (nonatomic, weak) id<CYScrollDelegate>delegate;

- (instancetype)initWithData:(NSArray *)data block:(selectedCell)block;

@end



